//
//  HomeViewController.m
//  SAILIN
//
//  Created by 崔国冠 on 2018/10/22.
//  Copyright © 2018年 赛麟. All rights reserved.
//

#import "HomeViewController.h"
#import "OpenCloseLockView.h"
#import "NotPromptBoxView.h"
#import "NISecurityPasswordView.h"
@interface HomeViewController ()

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIView *tableViewHeaderView;
@property (weak, nonatomic) IBOutlet UILabel *topTitle_lab; // 车况更新日期
@property (weak, nonatomic) IBOutlet UILabel *renewalMileage_lab;// 续航里程
@property (weak, nonatomic) IBOutlet UILabel *residual_lab;// 剩余电量
@property (weak, nonatomic) IBOutlet UILabel *totalMile_lab;// 总里程
@property (weak, nonatomic) IBOutlet UIImageView *carAbout_img;// 车况图片
@property (weak, nonatomic) IBOutlet UILabel *location_lab;// 定位位置

@end

@implementation HomeViewController
#pragma mark - Life Cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    
    [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"isEnableInteractivePop"];
    
    [self initUI];
}

-(void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    
    [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"isEnableInteractivePop"];
}

- (void)viewDidLayoutSubviews {
    
    [super viewDidLayoutSubviews];
    
    //修改tableHeaderView的frame
    self.tableView.tableHeaderView.frame = CGRectMake(0, 0, SIZE_SCREEN_WIDTH, SIZE_SCREEN_HEIGHT - kTopHeight - kTabBarHeight);

}
#pragma mark - UI
- (void)initUI{

    [self setTitle:@"赛麟"];
    [self setBackBtnWithImageName:@"home_scan" action:@selector(scanAction) target:self];
    [self setRightBtn1WithImageName:@"home_message" action:@selector(messageAction) target:self];
    [self setRightBtn2WithImageName:@"home_setting" action:@selector(settingAction) target:self];
    
    self.tableView.tableHeaderView = self.tableViewHeaderView;
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self.tableView.mj_header endRefreshing];
        NotPromptBoxView *notPromptBoxView = [NotPromptBoxView notPromptBoxView];
        notPromptBoxView.frame = CGRectMake(0, 0, SIZE_SCREEN_WIDTH, SIZE_SCREEN_HEIGHT);
        [notPromptBoxView show];
    }];
    
    [self enableSecurityPassword];
    
}
#pragma mark - Action
#pragma mark 扫一扫
- (void)scanAction{
    
    
}
#pragma mark 消息
- (void)messageAction{
    
    
}
#pragma mark 设置
- (void)settingAction{
    
    
}
#pragma mark 开锁
- (IBAction)closeBtnAction:(id)sender {
    NSLog(@"开锁");
    OpenCloseLockView *openCloseLockView = [OpenCloseLockView openCloseLockView];
    openCloseLockView.frame = CGRectMake(0, 0, SIZE_SCREEN_WIDTH, SIZE_SCREEN_HEIGHT);
    [openCloseLockView show];
    __weak typeof(openCloseLockView)weakOpenCloseLockView = openCloseLockView;
    openCloseLockView.openLockBtnBlock = ^{
        [self validateSecurityPassword];
        [weakOpenCloseLockView hidden];
    };
}
#pragma mark 空调
- (IBAction)airConditionerBtnAction:(id)sender {
    NSLog(@"空调");
}
#pragma mark 引擎
- (IBAction)engineBtnAction:(id)sender {
    NSLog(@"引擎");
}
#pragma mark - tableViewDelegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 0;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
